<?php
session_start();
$title="เปลี่ยนแปลงห้องพัก";
include ('header-admin.php');

$userID=$_SESSION["HBD_USER"];
?>

<div id="center-block" class="main-content">
<img src="img/door.png"/ id="img-block-content">
<div id="content-title-right" >
		<h2 class="caption-header">เปลี่ยนแปลงห้องพัก</h2>
		<span class="caption">ใช้สำหรับเปลี่ยนแปลงหัองพักหาดบ้านดินรีสอร์ท</span>
	</div><hr>
			
			<?php
			$sql="SELECT reservgroup.reserv_gid AS reserv_gid, reservgroup.room_list AS room_list, reservation.reserv_date AS reserv_date, reservation.reserv_begin AS reserv_begin, reservation.reserv_end AS reserv_end, reservation.reserv_etc AS reserv_etc, customer.customer_name AS customer_name, customer.customer_surname AS customer_surname, 
	   		MAX(reservation.reserv_status) AS reserv_current_status, reservgroup.reserv_gdetail AS reserv_gdetail
			FROM reservgroup
			INNER JOIN customer ON ( reservgroup.customer_id = customer.id )
			INNER JOIN reservation ON ( reservgroup.reserv_gid = reservation.reserv_gid )
   			WHERE reserv_status = '4'
   			GROUP BY reserv_gid
   			ORDER BY reserv_begin ASC";

	//$result = mysql_query($sql. " LIMIT " . $limit_start. "," . $limit_end);
	$result = mysql_query($sql);
	$count = mysql_num_rows($result);
	$total = mysql_num_rows(mysql_query($sql));
	$status = " ";
	$color = 0;
	$table_notconfirm = "";
	$table_confirmed = "";
	$table_checkined = "";
if($total > 0){
	while ($rs = mysql_fetch_array($result)){
			$status = 'เช็คอินแล้ว <img src="img/bullet_green.png" style="vertical-align: middle;">';
			if($table_confirmed_color%2 == 0){
				$table_confirmed .= '<tr class="odd">';
			}else{
				$table_confirmed .= '<tr>';
			}
			//echo '<tr class="odd">';
			$table_confirmed .= '<td>' . $rs['reserv_gid'] . '</a>';
			$table_confirmed .= '</td>';
			$table_confirmed .= '<td>' . $rs['reserv_begin'] . ' - ' .  $rs['reserv_end'] . '</td>';
			$table_confirmed .= '<td width="150px">' . $rs['room_list'] . '</td>';
			$table_confirmed .= '<td>' . $rs['customer_name'].' '.$rs['customer_surname']. '</td>';
			$table_confirmed .= '<td>' . $status . '</td>';
			$table_confirmed .= '<td>' . $rs['reserv_gdetail'] . '</td>';
			$table_confirmed .= '<td><a href="editBooking.php?reserv_id=' . $rs['reserv_gid'] . '&reserv_begin_o='. $rs['reserv_begin'].'&reserv_end_o='. $rs['reserv_end'].'"><img src="img/icon_edit.png" /></a></td>';
			$table_confirmed .= '</tr>';
			$table_confirmed_color++;
	}

//echo "\n<div style=\"float:left;\">Page : " . page_navi($page, $limit_end, 4, $total, null) . " </div><div style=\"float:right;\">[" . ($limit_start+1) . "-" . ($limit_start+$count) . "] of <strong>" . $total . "</strong></div>";
}
	?>	
	<table summary="Table confirmed" id="table">
		<thead>
		<tr>
		<th scope="col" abbr="reserv_id">เลขที่</th>
		<th scope="col" abbr="reserv_begin">วันที่พัก</th>
		<th scope="col" abbr="room_id">ห้อง</th>
		<th scope="col" abbr="customer_name">ชื่อ-นามสกุล ผู้จอง</th>
		<th scope="col" abbr="customer_name">สถานะ</th>
		<th scope="col" abbr="customer_name">รายละเอียด</th>
		<th scope="col" abbr="customer_name">จัดการ</th>
		</tr>	
		</thead>
		<tbody>
		<?php echo $table_confirmed;?>
		</tbody>
	</table>
	
	</div>
<?
include ('footer.php');
?>